#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   01-service.sh
# Version:    1.0
# Date:       2020/04/22
# Author:     Lz
# Email:      lz843723683@163.com
# History：     
#             Version 1.0, 2020/04/22
# Function:   server - 01测试基础服务
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
SvcClean_FTNS(){
	return $TPASS
}


## TODO: 用户界面
#
SvcUSAGE_FTNS(){
	USAGE_FTLIB "Feature - NS - 01默认关闭服务"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
SvcInit_FTNS(){
        # 调用初始化函数
	Init_FTLIB "SvcClean_FTNS"
        # 调用用户界面函数
 	SvcUSAGE_FTNS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
SvcExit_FTNS(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 测试默认关闭服务
#
SvcTest01(){
	local readonly serviceArr=(cpuspeed atd postfix)
	local index=""
	for index in ${serviceArr[@]}
	do
		chkconfig --list $index | grep "3.关闭" | grep "5.关闭" &> /dev/null
		RetParse_FTLIB "$index :3.关闭 , 5.关闭" "False"
		chkconfig --list $index
	done
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
SvcMain_FTNS(){
	SvcInit_FTNS

	SvcTest01

	return ${TPASS}	
}

SvcMain_FTNS
SvcExit_FTNS $?
